package com.spic.business.bp.controller;

import com.alibaba.fastjson.JSONObject;
import com.spic.business.bp.domain.BpAlarm;
import com.spic.business.bp.service.BpService;
import com.spic.common.core.web.controller.BaseController;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.common.core.web.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 290512
 * @create 2022-06-05 16:16
 */
@RestController
@RequestMapping("/bp")
public class BpAlarmController extends BaseController
{
    @Autowired
    private BpService bpService;

    @GetMapping("/list")
    public TableDataInfo list(BpAlarm bpAlarm)
    {
        startPage();
        List<BpAlarm> list = bpService.selectBpAlarmList(bpAlarm);
        return getDataTable(list);
    }
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(bpService.selectBpAlarmById(id));
    }

    @GetMapping("/bpAlarmList")
    public AjaxResult bpAlarmList(String spsType,String dayType){
        return AjaxResult.success(bpService.queryDataList( spsType,dayType));
    }

    @GetMapping("/bpCdData")
    public AjaxResult bpAlarmRemark(){
        return AjaxResult.success(bpService.bpCdData());
    }
    @GetMapping("/bpAlarmRemark")
    public AjaxResult bpAlarmRemark(String dayType){
        return AjaxResult.success(bpService.bpAlarmRemark(dayType));
    }

    @PostMapping("/saveBpGnss")
    public AjaxResult saveBpGnss(){
        bpService.saveBpGnss();
        return AjaxResult.success();
    }

    @PostMapping("/saveBpPositionData")
    public AjaxResult saveBpPositionData(){
        bpService.saveBpPositionData();
        return AjaxResult.success();
    }

    @PostMapping("/saveBpAlarm")
    public AjaxResult saveBpAlarm(){
        bpService.saveBpAlarm();
        return AjaxResult.success();
    }

    @PostMapping("/getBpAlarm")
    public AjaxResult getBpAlarm(){
        JSONObject json = bpService.getBpAlarms();
        return AjaxResult.success(json);
    }

    @GetMapping("/bpTest")
    public AjaxResult bpTest(){
        bpService.bpTest();
        return AjaxResult.success();
    }
}
